home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Multi / AppDelegate.h next >
Text File  |  1995-06-12  |  3KB  |  81 lines

  1. /*----------------------------------------------------------------------------
  2.    This is the "application delegate", the object messaged if the true
  3.      Application object doesn't understand a message.  We use this as a 
  4.      sort of substitute for main().  
  5.      
  6.      We're actually vended as a distributed object--other processes or
  7.      threads within this process can hook up to us and send us messages.
  8.      This is done to serialize output to the windowserver and appkit--
  9.      otherwise we run into problems with critical sections.
  10.      
  11.      We initialize some things in appDidInit:.  When the user hits one
  12.      of the menu items, we get the message and act upon it.
  13.      
  14.      This is not in any way, shape, or form optimized for speed.  There
  15.      are a bunch of things that could be done to speed things up.  The
  16.      biggest offendor is probably the CircleView class, which is banging
  17.      on the window server in various ways.
  18.      
  19.      This file is set up for a width of 130 columns, with tab stops
  20.      every two spaces.
  21.      
  22.      HISTORY 
  23.      
  24.          10Oct93    DM    New
  25. ----------------------------------------------------------------------------*/
  26.  
  27.  
  28. #import <appkit/appkit.h>
  29.  
  30.         // This is a formal protocol declaration of the object methods that must be implemented
  31.         // by our example server.  These are implemented in the .m file.
  32.         
  33. @protocol ServerInterface
  34.  
  35.     // The main methods called by the threads, which output things to the screen.
  36.     // All the data sent to these methods is strictly input.
  37.     
  38. - showIncreasing                                                // Show an increasing number in the text field
  39.     :(in int)pNumber;                                            // INPUT: the number to show
  40.     
  41. - showPrime                                                            // Show a prime number in the text field
  42.     :(in int)pPrime;                                            // INPUT: the prime to show
  43.     
  44. - showFib                                                                // Show a fibonaci number in the text field
  45.     :(in int)pFib;                                                // INPUT: the fib to show
  46.     
  47. - drawRandomCircleAt                                        // Draw a circle at the given point with the given radius
  48.     :(in NXPoint)pPoint                                        // INPUT: where to draw it at (the center)
  49.     withRadius:(in float)pRadius;                    // INPUT: the radius
  50.  
  51. @end
  52.  
  53.     // Adopt the ServerInterface protocol as our own.  We're a subclass of Object.
  54.     
  55. @interface AppDelegate:Object <ServerInterface>
  56. {
  57.     id            increasingDisp;                                // ScrollView that holds increasing number sequence
  58.     id            primeDisp;                                        // ScrollView that holds increasing prime sequence
  59.     id            fibDisp;                                            // ScrollView that holds increasing fibonacci sequence
  60.     id            circleView;                                        // View in which random circles are displayed
  61.     
  62.     NXConnection    *connection;                        // Our Distributed Object connection 
  63.     
  64. @public
  65.     BOOL        isRunning;
  66. }
  67.     
  68.  
  69. // App initialization delegate method
  70.  
  71. - appDidInit:sender;                                        // called after application object is initialized
  72.  
  73. - doThreads:sender;                                            // Starts doing things--slamming numbers to the screen.  Clears things out, too
  74. - stopThreads:sender;                                        // Stops all the treads
  75.  
  76. - addToText                                                            // Utility method--adds text at end of given text obj
  77.     :(Text*)pTextObj                                            // INPUT: text obj to add to
  78.     string:(char*)pString;                                // INPUT: the text we're adding
  79.  
  80. @end
  81.